package com.cc.wechat.mq.producer;

import com.cc.wechat.mq.constant.RabbitMQConstants;
import com.cc.wechat.websocket.message.WebSocketMessage;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

/**
 * 消息生产者
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class MessageProducer {

    private final RabbitTemplate rabbitTemplate;

    /**
     * 发送私聊消息
     */
    public void sendPrivateMessage(WebSocketMessage<?> message) {
        log.info("发送私聊消息到MQ：{}", message);
        rabbitTemplate.convertAndSend(RabbitMQConstants.PRIVATE_MESSAGE_QUEUE, message);
    }

    /**
     * 发送群聊消息
     */
    public void sendGroupMessage(WebSocketMessage<?> message) {
        log.info("发送群聊消息到MQ：{}", message);
        rabbitTemplate.convertAndSend(RabbitMQConstants.GROUP_MESSAGE_QUEUE, message);
    }

    /**
     * 发送好友请求
     */
    public void sendFriendRequest(WebSocketMessage<?> message) {
        log.info("发送好友请求到MQ：{}", message);
        rabbitTemplate.convertAndSend(RabbitMQConstants.FRIEND_REQUEST_QUEUE, message);
    }

    /**
     * 发送好友响应
     */
    public void sendFriendResponse(WebSocketMessage<?> message) {
        log.info("发送好友响应到MQ：{}", message);
        rabbitTemplate.convertAndSend(RabbitMQConstants.FRIEND_RESPONSE_QUEUE, message);
    }

    /**
     * 发送消息已读通知
     */
    public void sendMessageReadNotification(WebSocketMessage<?> message) {
        log.info("发送消息已读通知到MQ：{}", message);
        rabbitTemplate.convertAndSend(RabbitMQConstants.MESSAGE_READ_QUEUE, message);
    }

    /**
     * 发送消息撤回通知
     */
    public void sendMessageRecallNotification(WebSocketMessage<?> message) {
        log.info("发送消息撤回通知到MQ：{}", message);
        rabbitTemplate.convertAndSend(RabbitMQConstants.MESSAGE_RECALL_QUEUE, message);
    }
} 